/**
 * @author alexander.farkas
 * 
 * @version 2.5.3
 * project site: http://plugins.jquery.com/project/AjaxManager
 */

(function($){$.support.ajax=!!(window.XMLHttpRequest);var needActiveXFix=false;if(window.ActiveXObject){try{new ActiveXObject("Microsoft.XMLHTTP");$.support.ajax=true;}catch(e){$.support.ajax=false;if(window.XMLHttpRequest){$.ajaxSetup({xhr:function(){return new XMLHttpRequest();}});$.support.ajax=true;}}}
$.manageAjax=(function(){var cache={},queues={},presets={},activeRequest={},allRequests={},triggerEndCache={},defaults={queue:true,maxRequests:1,abortOld:false,preventDoubbleRequests:true,cacheResponse:false,complete:function(){},error:function(ahr,status){var opts=this;if(status&&status.indexOf('error')!=-1){setTimeout(function(){var errStr=status+': ';if(ahr.status){errStr+='status: '+ahr.status+' | ';}
errStr+='URL: '+opts.url;throw new Error(errStr);},1);}},success:function(){},abort:function(){}};function create(name,settings){var publicMethods={};presets[name]=presets[name]||{};$.extend(true,presets[name],$.ajaxSettings,defaults,settings);if(!allRequests[name]){allRequests[name]={};activeRequest[name]={};activeRequest[name].queue=[];queues[name]=[];triggerEndCache[name]=[];}
$.each($.manageAjax,function(fnName,fn){if($.isFunction(fn)&&fnName.indexOf('_')!==0){publicMethods[fnName]=function(param,param2){if(param2&&typeof param==='string'){param=param2;}
fn(name,param);};}});return publicMethods;}
function complete(opts,args){if(args[1]=='success'||args[1]=='notmodified'){opts.success.apply(opts,[args[0].successData,args[1]]);if(opts.global){$.event.trigger("ajaxSuccess",args);}}
if(args[1]==='abort'){opts.abort.apply(opts,args);if(opts.global){$.active--;$.event.trigger("ajaxAbort",args);}}
opts.complete.apply(opts,args);if(opts.global){$.event.trigger("ajaxComplete",args);}
if(opts.global&&!$.active){$.event.trigger("ajaxStop");}}
function proxy(oldFn,fn){return function(xhr,s,e){fn.call(this,xhr,s,e);oldFn.call(this,xhr,s,e);xhr=null;e=null;};}
function callQueueFn(name){var q=queues[name];if(q&&q.length){var fn=q.shift();if(fn){fn();}}}
function add(name,opts){if(!presets[name]){create(name,opts);}
opts=$.extend({},presets[name],opts);var allR=allRequests[name],activeR=activeRequest[name],queue=queues[name];var id=opts.type+'_'+opts.url.replace(/\./g,'_'),triggerStart=true,oldComplete=opts.complete,ajaxFn=function(){activeR.queue.push(id);activeR[id]={xhr:false,ajaxManagerOpts:opts};activeR[id].xhr=$.ajax(opts);return id;};if(opts.data){id+=(typeof opts.data=='string')?opts.data:$.param(opts.data);}
if(opts.preventDoubbleRequests&&allRequests[name][id]){return false;}
allR[id]=true;opts.complete=function(xhr,s,e){var triggerEnd=true;if(opts.abortOld){$.each(activeR.queue,function(i,activeID){if(activeID==id){return false;}
abort(name,activeID);return activeID;});}
oldComplete.call(this,xhr,s,e);if(activeRequest[name][id]){if(activeRequest[name][id]&&activeRequest[name][id].xhr){activeRequest[name][id].xhr=null;}
activeRequest[name][id]=null;}
triggerEndCache[name].push({xhr:xhr,status:s});xhr=null;activeRequest[name].queue=$.grep(activeRequest[name].queue,function(qid){return(qid!==id);});allR[id]=false;e=null;delete activeRequest[name][id];$.each(activeR,function(id,queueRunning){if(id!=='queue'||queueRunning.length){triggerEnd=false;return false;}});if(triggerEnd){$.event.trigger(name+'End',[triggerEndCache[name]]);$.each(triggerEndCache[name],function(i,cached){cached.xhr=null;});triggerEndCache[name]=[];}};if(cache[id]){ajaxFn=function(){activeR.queue.push(id);complete(opts,cache[id]);return id;};}else if(opts.cacheResponse){opts.complete=proxy(opts.complete,function(xhr,s){if(s!=="success"&&s!=="notmodified"){return false;}
cache[id][0].responseXML=xhr.responseXML;cache[id][0].responseText=xhr.responseText;cache[id][1]=s;xhr=null;return id;});opts.success=proxy(opts.success,function(data,s){cache[id]=[{successData:data,ajaxManagerOpts:opts},s];data=null;});}
ajaxFn.ajaxID=id;$.each(activeR,function(id,queueRunning){if(id!=='queue'||queueRunning.length){triggerStart=false;return false;}});if(triggerStart){$.event.trigger(name+'Start');}
if(opts.queue){opts.complete=proxy(opts.complete,function(){callQueueFn(name);});if(opts.queue==='clear'){queue=clear(name);}
queue.push(ajaxFn);if(activeR.queue.length<opts.maxRequests){callQueueFn(name);}
return id;}
return ajaxFn();}
function clear(name,shouldAbort){$.each(queues[name],function(i,fn){allRequests[name][fn.ajaxID]=false;});queues[name]=[];if(shouldAbort){abort(name);}
return queues[name];}
function getXHR(name,id){var ar=activeRequest[name];if(!ar||!allRequests[name][id]){return false;}
if(ar[id]){return ar[id].xhr;}
var queue=queues[name],xhrFn;$.each(queue,function(i,fn){if(fn.ajaxID==id){xhrFn=[fn,i];return false;}
return xhrFn;});return xhrFn;}
function abort(name,id){var ar=activeRequest[name];if(!ar){return false;}
function abortID(qid){if(qid!=='queue'&&ar[qid]&&ar[qid].xhr){try{ar[qid].xhr.abort();}catch(e){}
complete(ar[qid].ajaxManagerOpts,[ar[qid].xhr,'abort']);}
return null;}
if(id){return abortID(id);}
return $.each(ar,abortID);}
function unload(){$.each(presets,function(name){clear(name,true);});cache={};}
return{defaults:defaults,add:add,create:create,cache:cache,abort:abort,clear:clear,getXHR:getXHR,_activeRequest:activeRequest,_complete:complete,_allRequests:allRequests,_unload:unload};})();$(window).unload($.manageAjax._unload);})(jQuery);


/**
*	jQuery.noticeAdd() and jQuery.noticeRemove()
*	These functions create and remove growl-like notices
*		
*   Copyright (c) 2009 Tim Benniks
*
*	Permission is hereby granted, free of charge, to any person obtaining a copy
*	of this software and associated documentation files (the "Software"), to deal
*	in the Software without restriction, including without limitation the rights
*	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*	copies of the Software, and to permit persons to whom the Software is
*	furnished to do so, subject to the following conditions:
*
*	The above copyright notice and this permission notice shall be included in
*	all copies or substantial portions of the Software.
*
*	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*	THE SOFTWARE.
*	
*	@author 	Tim Benniks <tim@timbenniks.com>
* 	@copyright  2009 timbenniks.com
*	@version    $Id: jquery.notice.js 1 2009-01-24 12:24:18Z timbenniks $
**/
 
(function(jQuery)
{jQuery.extend({noticeAdd:function(options)
{var defaults={inEffect:{opacity:'show'},inEffectDuration:600,stayTime:3000,text:'',stay:false,type:'notice'}
var options,noticeWrapAll,noticeItemOuter,noticeItemInner,noticeItemClose;options=jQuery.extend({},defaults,options);noticeWrapAll=(!jQuery('.notice-wrap').length)?jQuery('<div></div>').addClass('notice-wrap').appendTo('body'):jQuery('.notice-wrap');noticeItemOuter=jQuery('<div></div>').addClass('notice-item-wrapper');noticeItemInner=jQuery('<div></div>').hide().addClass('notice-item '+options.type).appendTo(noticeWrapAll).html('<p>'+options.text+'</p>').animate(options.inEffect,options.inEffectDuration).wrap(noticeItemOuter);noticeItemClose=jQuery('<div></div>').addClass('notice-item-close').prependTo(noticeItemInner).html('x').click(function(){jQuery.noticeRemove(noticeItemInner)});if(navigator.userAgent.match(/MSIE 6/i))
{noticeWrapAll.css({top:document.documentElement.scrollTop});}
if(!options.stay)
{setTimeout(function()
{jQuery.noticeRemove(noticeItemInner);},options.stayTime);}},noticeRemove:function(obj)
{obj.animate({opacity:'0'},600,function()
{obj.parent().animate({height:'0px'},300,function()
{obj.parent().remove();});});}});})(jQuery);


/*  
===============================================================================
Chili is the jQuery code highlighter plugin
...............................................................................
                                               Copyright 2007 / Andrea Ercolino
-------------------------------------------------------------------------------
LICENSE: http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/chili/
===============================================================================

===============================================================================
Metaobjects is the jQuery metadata plugin on steroids
...............................................................................
                                               Copyright 2007 / Andrea Ercolino
-------------------------------------------------------------------------------
LICENSE: http://www.opensource.org/licenses/mit-license.php
WEBSITE: http://noteslog.com/metaobjects/
===============================================================================
*/

(function($){ChiliBook={version:"1.8b",automatic:true,automaticSelector:"code",codeLanguage:function(el){var recipeName=$(el).attr("class");return recipeName?recipeName:'';},metadataSelector:"object.chili",recipeLoading:true,recipeFolder:"",stylesheetLoading:true,stylesheetFolder:"",defaultReplacement:'<span class="$0">$$</span>',replaceSpace:" ",replaceTab:"    ",replaceNewLine:" <br/>",recipes:{},queue:{},preFixCopy:document.selection&&document.selection.createRange,preContent:"",preElement:null};$.metaobjects=function(options){options=$.extend({context:document,clean:true,selector:'object.metaobject'},options);function jsValue(value){eval('value = '+value+";");return value;}
return $(options.selector,options.context).each(function(){var settings={target:this.parentNode};$('> param[@name=metaparam]',this).each(function(){$.extend(settings,jsValue(this.value));});$('> param',this).not('[@name=metaparam]').each(function(){var name=this.name,value=jsValue(this.value);$(settings.target).each(function(){this[name]=value;});});if(options.clean){$(this).remove();}});};$.fn.chili=function(options){var book=$.extend({},ChiliBook,options||{});function cook(ingredients,recipe){function prepareStep(stepName,step){var exp=(typeof step.exp=="string")?step.exp:step.exp.source;steps.push({stepName:stepName,exp:"("+exp+")",length:1
+(exp.replace(/\\./g,"%").replace(/\[.*?\]/g,"%").match(/\((?!\?)/g)||[]).length,replacement:(step.replacement)?step.replacement:book.defaultReplacement});}
function knowHow(){var prevLength=0;var exps=new Array;for(var i=0;i<steps.length;i++){var exp=steps[i].exp;exp=exp.replace(/\\\\|\\(\d+)/g,function(m,aNum){return!aNum?m:"\\"+(prevLength+1+parseInt(aNum,10));});exps.push(exp);prevLength+=steps[i].length;}
var source=exps.join("|");return new RegExp(source,(recipe.ignoreCase)?"gi":"g");}
function escapeHTML(str){return str.replace(/&/g,"&").replace(/</g,"<");}
function replaceSpaces(str){return str.replace(/ +/g,function(spaces){return spaces.replace(/ /g,replaceSpace);});}
function filter(str){str=escapeHTML(str);if(replaceSpace){str=replaceSpaces(str);}
return str;}
function chef(matched){var i=0;var j=1;var step;while(step=steps[i++]){var aux=arguments;if(aux[j]){var pattern=/(\\\$)|(?:\$\$)|(?:\$(\d+))/g;var replacement=step.replacement.replace(pattern,function(m,escaped,K){var bit='';if(escaped){return"$";}
else if(!K){return filter(aux[j]);}
else if(K=="0"){return step.stepName;}
else{return filter(aux[j+parseInt(K,10)]);}});var offset=arguments[arguments.length-2];var input=arguments[arguments.length-1];var unmatched=input.substring(lastIndex,offset);lastIndex=offset+matched.length;perfect+=filter(unmatched)+replacement;return replacement;}
else{j+=step.length;}}}
var replaceSpace=book.replaceSpace;var steps=new Array;for(var stepName in recipe.steps){prepareStep(stepName,recipe.steps[stepName]);}
var perfect="";var lastIndex=0;ingredients.replace(knowHow(),chef);var lastUnmatched=ingredients.substring(lastIndex,ingredients.length);perfect+=filter(lastUnmatched);return perfect;}
function checkCSS(stylesheetPath){if(!book.queue[stylesheetPath]){var e=document.createElement("link");e.rel="stylesheet";e.type="text/css";e.href=stylesheetPath;document.getElementsByTagName("head")[0].appendChild(e);book.queue[stylesheetPath]=true;}}
function makeDish(el,recipePath){var recipe=book.recipes[recipePath];if(!recipe){return;}
var chunks=el&&el.childNodes&&el.childNodes.length;if(chunks&&chunks>1){return;}
var ingredients=el.childNodes[0]&&el.childNodes[0].data;if(!ingredients){return;}
ingredients=ingredients.replace(/\r\n?/g,"\n");var dish=cook(ingredients,recipe);if(book.replaceTab){dish=dish.replace(/\t/g,book.replaceTab);}
if(book.replaceNewLine){dish=dish.replace(/\n/g,book.replaceNewLine);}
$(el).html(dish);if(ChiliBook.preFixCopy){$(el).parents().filter("pre").bind("mousedown",function(){ChiliBook.preElement=this;}).bind("mouseup",function(){if(ChiliBook.preElement==this){ChiliBook.preContent=document.selection.createRange().htmlText;}});}}
function getPath(recipeName,options){var settingsDef={recipeFolder:book.recipeFolder,recipeFile:recipeName+".js",stylesheetFolder:book.stylesheetFolder,stylesheetFile:recipeName+".css"};var settings;if(options&&typeof options=="object"){settings=$.extend(settingsDef,options);}
else{settings=settingsDef;}
return{recipe:settings.recipeFolder+settings.recipeFile,stylesheet:settings.stylesheetFolder+settings.stylesheetFile};}
if(book.metadataSelector){$.metaobjects({context:this,selector:book.metadataSelector});}
this.each(function(){var el=this;var recipeName=book.codeLanguage(el);if(''!=recipeName){var path=getPath(recipeName,el.chili);if(book.recipeLoading||el.chili){if(!book.queue[path.recipe]){try{book.queue[path.recipe]=[el];$.getJSON(path.recipe,function(recipeLoaded){recipeLoaded.path=path.recipe;book.recipes[path.recipe]=recipeLoaded;if(book.stylesheetLoading){checkCSS(path.stylesheet);}
var q=book.queue[path.recipe];for(var i=0,iTop=q.length;i<iTop;i++){makeDish(q[i],path.recipe);}});}
catch(recipeNotAvailable){alert("the recipe for '"+recipeName+"' was not found in '"+path.recipe+"'");}}
else{book.queue[path.recipe].push(el);}
makeDish(el,path.recipe);}
else{makeDish(el,path.recipe);}}});return this;};$(function(){if(ChiliBook.automatic){if(ChiliBook.elementPath){ChiliBook.automaticSelector=ChiliBook.elementPath;if(ChiliBook.elementClass){ChiliBook.codeLanguage=function(el){var selectClass=new RegExp("\\b"+ChiliBook.elementClass+"\\b","gi");var elClass=$(el).attr("class");if(!elClass){return'';}
var recipeName=$.trim(elClass.replace(selectClass,""));return recipeName;};}}
$(ChiliBook.automaticSelector).chili();}
if(ChiliBook.preFixCopy){function preformatted(text){if(''==text){return"";}
do{var newline_flag=(new Date()).valueOf();}
while(text.indexOf(newline_flag)>-1);text=text.replace(/\<br[^>]*?\>/ig,newline_flag);var el=document.createElement('<pre>');el.innerHTML=text;text=el.innerText.replace(new RegExp(newline_flag,"g"),'\r\n');return text;}
$("body").bind("copy",function(){if(''!=ChiliBook.preContent){window.clipboardData.setData('Text',preformatted(ChiliBook.preContent));event.returnValue=false;}}).bind("mousedown",function(){ChiliBook.preContent="";}).bind("mouseup",function(){ChiliBook.preElement=null;});}});})(jQuery);


/* docs.js */
/*
if($.browser.msie==true)document.execCommand('BackgroundImageCache',false,true);ChiliBook.recipeFolder="js/chili/";ChiliBook.stylesheetFolder="js/chili/"
jQuery.fn.antispam=function(){return this.each(function(){var email=$(this).text().toLowerCase().replace(/\sdot/g,'.').replace(/\sat/g,'@').replace(/\s+/g,'');var URI="mailto:"+email;$(this).hide().before($("<a></a>").attr("href",URI).addClass("external").text(email));});};$(function(){$("pre.javascript").chili();$("pre.html").chili();$("pre.css").chili();$("a.external").each(function(){this.target='_new'});$("span.email").antispam();});
*/

/*
* jQuery Highlight plugin
*
* Based on highlight v3 by Johann Burkard
* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
*
* Copyright (c) 2009 Bartek Szopka
*
* Licensed under MIT license.
*
*/

jQuery.extend({highlight:function(node,re,nodeName,className){if(node.nodeType===3){var match=node.data.match(re);if(match){var highlight=document.createElement(nodeName||'span');highlight.className=className||'highlight';var wordNode=node.splitText(match.index);wordNode.splitText(match[0].length);var wordClone=wordNode.cloneNode(true);highlight.appendChild(wordClone);wordNode.parentNode.replaceChild(highlight,wordNode);return 1;}}else if((node.nodeType===1&&node.childNodes)&&!/(script|style)/i.test(node.tagName)&&!(node.tagName===nodeName.toUpperCase()&&node.className===className)){for(var i=0;i<node.childNodes.length;i++){i+=jQuery.highlight(node.childNodes[i],re,nodeName,className);}}
return 0;}});jQuery.fn.unhighlight=function(options){var settings={className:'highlight',element:'span'};jQuery.extend(settings,options);return this.find(settings.element+"."+settings.className).each(function(){var parent=this.parentNode;parent.replaceChild(this.firstChild,this);parent.normalize();}).end();};jQuery.fn.highlight=function(words,options){var settings={className:'highlight',element:'span',caseSensitive:false,wordsOnly:false};jQuery.extend(settings,options);if(words.constructor===String){words=[words];}
var flag=settings.caseSensitive?"":"i";var pattern="("+words.join("|")+")";if(settings.wordsOnly){pattern="\\b"+pattern+"\\b";}
var re=new RegExp(pattern,flag);return this.each(function(){jQuery.highlight(this,re,settings.element,settings.className);});};


/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};


/*
 * jQuery Easing v1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php
 *
 * Uses the built in easing capabilities added in jQuery 1.1
 * to offer multiple easing options
 *
 * Copyright (c) 2007 George Smith
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
 
jQuery.easing={easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var a=t-d/2;return-2*c*a*a/(d*d)+2*c*a/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}if(t<d/2)return a*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return a*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}};


/**
 * LavaLamp - A menu plugin for jQuery with cool hover effects.
 * @requires jQuery v1.1.3.1 or above
 *
 * http://gmarwaha.com/blog/?p=7
 *
 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 0.2.0
 * Requires Jquery 1.2.1 from version 0.2.0 onwards. 
 * For jquery 1.1.x, use version 0.1.0 of lavalamp
 */

(function($){$.fn.lavaLamp=function(o){o=$.extend({fx:"linear",speed:500,click:function(){}},o||{});return this.each(function(){var me=$(this),noop=function(){},$back=$('<li class="back"><div class="left"></div></li>').appendTo(me),$li=$("li",this),curr=$("li.current",this)[0]||$($li[0]).addClass("current")[0];$li.not(".back").hover(function(){move(this);},noop);$(this).hover(noop,function(){move(curr);});$li.click(function(e){setCurr(this);return o.click.apply(this,[e,this]);});setCurr(curr);function setCurr(el){$back.css({"left":el.offsetLeft+"px","width":el.offsetWidth+"px"});curr=el;};function move(el){$back.each(function(){$(this).dequeue();}).animate({width:el.offsetWidth,left:el.offsetLeft},o.speed,o.fx);};});};})(jQuery);


/*
 * Treeview 1.4 - jQuery plugin to hide and show branches of a tree
 * 
 * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
 * http://docs.jquery.com/Plugins/Treeview
 *
 * Copyright (c) 2007 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
 *
 */;(function($){$.extend($.fn,{swapClass:function(c1,c2){var c1Elements=this.filter('.'+c1);this.filter('.'+c2).removeClass(c2).addClass(c1);c1Elements.removeClass(c1).addClass(c2);return this;},replaceClass:function(c1,c2){return this.filter('.'+c1).removeClass(c1).addClass(c2).end();},hoverClass:function(className){className=className||"hover";return this.hover(function(){$(this).addClass(className);},function(){$(this).removeClass(className);});},heightToggle:function(animated,callback){animated?this.animate({height:"toggle"},animated,callback):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();if(callback)callback.apply(this,arguments);});},heightHide:function(animated,callback){if(animated){this.animate({height:"hide"},animated,callback);}else{this.hide();if(callback)this.each(callback);}},prepareBranches:function(settings){if(!settings.prerendered){this.filter(":last-child:not(ul)").addClass(CLASSES.last);this.filter((settings.collapsed?"":"."+CLASSES.closed)+":not(."+CLASSES.open+")").find(">ul").hide();}return this.filter(":has(>ul)");},applyClasses:function(settings,toggler){this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event){toggler.apply($(this).next());}).add($("a",this)).hoverClass();if(!settings.prerendered){this.filter(":has(>ul:hidden)").addClass(CLASSES.expandable).replaceClass(CLASSES.last,CLASSES.lastExpandable);this.not(":has(>ul:hidden)").addClass(CLASSES.collapsable).replaceClass(CLASSES.last,CLASSES.lastCollapsable);this.prepend("<div class=\""+CLASSES.hitarea+"\"/>").find("div."+CLASSES.hitarea).each(function(){var classes="";$.each($(this).parent().attr("class").split(" "),function(){classes+=this+"-hitarea ";});$(this).addClass(classes);});}this.find("div."+CLASSES.hitarea).click(toggler);},treeview:function(settings){settings=$.extend({cookieId:"treeview"},settings);if(settings.add){return this.trigger("add",[settings.add]);}if(settings.toggle){var callback=settings.toggle;settings.toggle=function(){return callback.apply($(this).parent()[0],arguments);};}function treeController(tree,control){function handler(filter){return function(){toggler.apply($("div."+CLASSES.hitarea,tree).filter(function(){return filter?$(this).parent("."+filter).length:true;}));return false;};}$("a:eq(0)",control).click(handler(CLASSES.collapsable));$("a:eq(1)",control).click(handler(CLASSES.expandable));$("a:eq(2)",control).click(handler());}function toggler(){$(this).parent().find(">.hitarea").swapClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).swapClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().swapClass(CLASSES.collapsable,CLASSES.expandable).swapClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightToggle(settings.animated,settings.toggle);if(settings.unique){$(this).parent().siblings().find(">.hitarea").replaceClass(CLASSES.collapsableHitarea,CLASSES.expandableHitarea).replaceClass(CLASSES.lastCollapsableHitarea,CLASSES.lastExpandableHitarea).end().replaceClass(CLASSES.collapsable,CLASSES.expandable).replaceClass(CLASSES.lastCollapsable,CLASSES.lastExpandable).find(">ul").heightHide(settings.animated,settings.toggle);}}function serialize(){function binary(arg){return arg?1:0;}var data=[];branches.each(function(i,e){data[i]=$(e).is(":has(>ul:visible)")?1:0;});$.cookie(settings.cookieId,data.join(""));}function deserialize(){var stored=$.cookie(settings.cookieId);if(stored){var data=stored.split("");branches.each(function(i,e){$(e).find(">ul")[parseInt(data[i])?"show":"hide"]();});}}this.addClass("treeview");var branches=this.find("li").prepareBranches(settings);switch(settings.persist){case"cookie":var toggleCallback=settings.toggle;settings.toggle=function(){serialize();if(toggleCallback){toggleCallback.apply(this,arguments);}};deserialize();break;case"location":var current=this.find("a").filter(function(){return this.href.toLowerCase()==location.href.toLowerCase();});if(current.length){current.addClass("selected").parents("ul, li").add(current.next()).show();}break;}branches.applyClasses(settings,toggler);if(settings.control){treeController(this,settings.control);$(settings.control).show();}return this.bind("add",function(event,branches){$(branches).prev().removeClass(CLASSES.last).removeClass(CLASSES.lastCollapsable).removeClass(CLASSES.lastExpandable).find(">.hitarea").removeClass(CLASSES.lastCollapsableHitarea).removeClass(CLASSES.lastExpandableHitarea);$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings,toggler);});}});var CLASSES=$.fn.treeview.classes={open:"open",closed:"closed",expandable:"expandable",expandableHitarea:"expandable-hitarea",lastExpandableHitarea:"lastExpandable-hitarea",collapsable:"collapsable",collapsableHitarea:"collapsable-hitarea",lastCollapsableHitarea:"lastCollapsable-hitarea",lastCollapsable:"lastCollapsable",lastExpandable:"lastExpandable",last:"last",hitarea:"hitarea"};$.fn.Treeview=$.fn.treeview;})(jQuery);


/*
 * 
 * TableSorter 2.0 - Client-side table sorting with ease!
 * Version 2.0.3
 * @requires jQuery v1.2.3
 * 
 * Copyright (c) 2007 Christian Bach
 * Examples and docs at: http://tablesorter.com
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 */

(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"uk",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}
this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}
function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}
var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}
if(!p){p=detectParserForColumn(table,cells[i]);}
if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}
list.push(p);}}
if(table.config.debug){log(parsersDebug);}
return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}
return parsers[0];}
function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}
return false;}
function buildCache(table){if(table.config.debug){var cacheTime=new Date();}
var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}
cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}
return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}
return t;}
function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}
var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}
if(table.config.appender){table.config.appender(table,rows);}
rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}
applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}
var meta=($.metadata)?true:false,tableHeadersRows=[];for(var i=0;i<table.tHead.rows.length;i++){tableHeadersRows[i]=0;};$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}
table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}
return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}
return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}
function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}
function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}
function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}
return i;}
function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}
return false;}
function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}
function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}
function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}
function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}
var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}
var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}
dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}
return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}
config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}
if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}
applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}
if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}
empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}
return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}
return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}
$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);


/* ontologyScript.js */
//--------------------------
// ontology generation and management
function push(a, el) {
  for (var i=0; i < a.length; i++){
    if(a[i].name==el.name) return;
  }
 a[a.length] = el;
}

function splice(arr, i, count) {
  copy = new Array();
  for (k=0; k < arr.length; k++) {
    if (k >= i && k < i+count)
      continue;
    push(copy, arr[k]);
  }
  return copy;
}

function Class( name, label, superClass ) {
    this.name = name;
    this.label = label;
    this.supClass = superClass;
    this.children = new Array();
    if (superClass != null) {
        push(superClass.children, this);
    }

    this.props = new Array();
    this.attribs = new Array();
} // Class


function addProperty( aClass, aProperty ) {
    push(aClass.props,aProperty);
    for (var i=0; i < aClass.children.length; i++)
        addProperty(aClass.children[i], aProperty);
} // addProperty

function addAttribute( aClass, anAttribute ) {
    push(aClass.attribs,anAttribute);

    for (var i=0; i < aClass.children.length; i++)
        addAttribute(aClass.children[i], anAttribute);
} // addAttribute


function addPropertyRange( aProperty, aClass ) {
    push(aProperty.range,aClass);

//    for (var i=0; i < aClass.children.length; i++)
//        addProperty(aClass.children[i], aProperty);
} // addProperty

//------------------------------
// a property with range other than literal

function Property( name, label) {
    this.name = name;
    this.label = label;
    this.children = new Array();
    this.range =  new Array();
//    this.domains = new Array();
} // Class

//------------------------------
// a property with range Literal

function Attribute( name, label) {
    this.name = name;
    this.label = label;
    this.children = new Array();
    this.range =  new Array();
//    this.domains = new Array();
} // Class



/* queryScript.js */
function encode(val) {
	var obj = document.getElementById(val);
	var unencoded = trim(obj.value);
	str = encodeURIComponent(unencoded);
	return str;
}
function decode(val) {
	var obj = document.getElementById(val);
	var encoded = obj.value;
	return decodeURIComponent(encoded.replace(/\+/g,  " "));
}

function attrFocus() {

//alert(document.f1.classX.value + " " + document.f1.classY.value + " " + document.f1.classZ.value)
	if (typeof(document.f1.classX) != "undefined" && typeof(document.f1.classY) != "undefined" && document.f1.classX.value != "" && document.f1.classY.value == "") {
		attrRestrX();
		attrRestrY();
		attrRestrZ();
		//alert("X");
	} else if (typeof(document.f1.classY) != "undefined" && typeof(document.f1.classZ) != "undefined" && document.f1.classY.value != "" && document.f1.classZ.value == "") {
		attrRestrY();
		attrRestrZ();
		//alert("X and Y");
	} else if (typeof(document.f1.classZ) != "undefined" && document.f1.classZ.value != "") {
		attrRestrZ();
		//alert("X, Y and Z");
	}

}

function escapeVal(s) {
  var retStr = escape(s);
  // replace all unicode symbols
  var ix = retStr.indexOf("%");
  while(ix >= 0){
    if(ix+1 > retStr.length){
      retStr = retStr.substring(0, ix) + "\\\\";
    }else{
      retStr = retStr.substring(0, ix) + "\\\\" + retStr.substring(ix+1);
    }
    ix = retStr.indexOf("%", ix+2);
  }

  // replace all spaces back
  ix = retStr.indexOf("\\\\20");
  while(ix >= 0){
    if(ix+1 > retStr.length){
      retStr = retStr.substring(0, ix) + "%20";
    }else{
      retStr = retStr.substring(0, ix) + "%20" + retStr.substring(ix+4);
    }
    ix = retStr.indexOf("\\\\20", ix+3);
  }

  return retStr;
}

//--------------------------
// form elements generation and management

varChoice0 = "X";


function literalExpr( fieldName  ) {

    document.write("<select class=\"select\" name=\"" + fieldName + "\" onChange=\"literalExprOnChange(" + fieldName + ");\">");
    document.write("<option value=\"is unknown\">is unknown</option>");
    document.write("<option value=\"is exactly =\">is exactly =</option>");
    document.write("<option value=\"starts with\">starts with</option>");
    document.write("<option value=\"ends with\">ends with</option>");
    document.write("<option value=\"contains\">contains</option>");
    document.write("<option value=\"is &lt; (before)\"> is &lt; (before)</option>");
    document.write("<option value=\"is &gt; (after)\"> is &gt; (after)</option>");
    document.write("<option value=\"equals ignore case\">equals ignore case</option>");
    document.write("</select> ");

} // literalExpr

function literalExprOnChange(fieldName) {

	if (document.f1.nameX.selectedIndex != 0) {
		document.getElementById("xtext").style.visibility = "visible";
		document.getElementById("xtext").style.height = "60px";
		} else {
		document.getElementById("xtext").style.visibility = "hidden";
		document.getElementById("xtext").style.height = "1px";
		}

	if (document.f1.nameY.selectedIndex != 0) {
		document.getElementById("ytext").style.visibility = "visible";
		document.getElementById("ytext").style.height = "60px";
		} else {
		document.getElementById("ytext").style.visibility = "hidden";
		document.getElementById("ytext").style.height = "1px";
		}

	if (document.f1.nameZ.selectedIndex != 0) {
		document.getElementById("ztext").style.visibility = "visible";
		document.getElementById("ztext").style.height = "60px";
		} else {
		document.getElementById("ztext").style.visibility = "hidden";
		document.getElementById("ztext").style.height = "1px";
		}
		
	if (document.f1.attrExpr1.selectedIndex != 0) {
		document.getElementById("attrEx1").style.visibility = "visible";
		document.getElementById("attrEx1").style.height = "60px";
		} else {
		document.getElementById("attrEx1").style.visibility = "hidden";
		document.getElementById("attrEx1").style.height = "1px";
		}

	if (document.f1.attrExpr2.selectedIndex != 0) {
		document.getElementById("attrEx2").style.visibility = "visible";
		document.getElementById("attrEx2").style.height = "60px";
		} else {
		document.getElementById("attrEx2").style.visibility = "hidden";
		document.getElementById("attrEx2").style.height = "1px";
		}

	if (document.f1.attrExpr3.selectedIndex != 0) {
		document.getElementById("attrEx3").style.visibility = "visible";
		document.getElementById("attrEx3").style.height = "60px";
		} else {
		document.getElementById("attrEx3").style.visibility = "hidden";
		document.getElementById("attrEx3").style.height = "1px";
		}

}

//-----------------------------
// class Select/combobox

function classSel( fieldName ) {
    document.write( "<select style=\"width:180px\" class=\"select\" name=\"" + fieldName + "\"");
    document.write(" onChange=\"{classSelOnChange(" + fieldName + ");attrFocus();propcheck();}\">");
    document.write("</select>");
    theSel = document.f1.elements[fieldName];
    theSel.dependent = new Array();
} // classSel

function checkClasses () {
	if ((document.f1.refSel.selectedIndex == 1) && (document.f1.classY.value == "")) {
		//alert("Pattern for Y class is empty."); 
		document.getElementById("errMsg").innerHTML = "* Please, select a pattern for Y first.";
		setTimeout('document.getElementById("errMsg").innerHTML = ""', 3000);
		document.f1.refSel.options[0].selected = true;
	}
		if ((document.f1.refSel.selectedIndex == 2) && (document.f1.classZ.value == "")) {
		//alert("Pattern for Z class is empty."); 
		document.getElementById('errMsg').innerHTML = "* Please, select a pattern for Z first.";
		setTimeout('document.getElementById("errMsg").innerHTML = ""', 3000);
		document.f1.refSel.options[0].selected = true;
	}
		if ((document.f1.refSel.selectedIndex == 3) && ((document.f1.classY.value == "") && (document.f1.classZ.value == ""))) {
		//alert("Pattern for Y or Z classes is empty."); 
		document.getElementById('errMsg').innerHTML = "* Please, select a patterns for Y and Z first.";
		setTimeout('document.getElementById("errMsg").innerHTML = ""', 3000);
		document.f1.refSel.options[0].selected = true;
	}
		if ((document.f1.refSel.selectedIndex == 3) && ((document.f1.classY.value != "") && (document.f1.classZ.value == ""))) {
		//alert("Pattern for Y or Z classes is empty."); 
		document.getElementById('errMsg').innerHTML = "* Please, select a patterns for Z first.";
		setTimeout('document.getElementById("errMsg").innerHTML = ""', 3000);
		document.f1.refSel.options[0].selected = true;
	}
}

function isUrl(s) {
    // URIs like urn:lsid:ontotext.com:kim:iextraction:GeneOntologyTerm should be allowed
    return true; 
    
	var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	var str = document.f1.ADDITIONAL_TYPE_RESTRICTION.value;
	//return regexp.test(s);
	if (regexp.test(s) || str == "") {
		return true;
	} else {
		//alert("You've entered invalid URI. It has to start with \"http://\" and must be a valid address. \nExample: http://proton.semanticweb.org/2005/04/protons#Entity");
		//if (str.indexOf("http://") == -1) {
		//	document.f1.ADDITIONAL_TYPE_RESTRICTION.value = "http://" + document.f1.ADDITIONAL_TYPE_RESTRICTION.value;
		//} else if (str.indexOf("http://") == 0) {
		//	document.f1.ADDITIONAL_TYPE_RESTRICTION.value = document.f1.ADDITIONAL_TYPE_RESTRICTION.value;
		//} else {
		//	document.f1.ADDITIONAL_TYPE_RESTRICTION.value = "http://";
		//}
		//document.getElementById("invalidURI").innerHTML = "* Invalid URI. It has to start with \"http://\"";
		document.f1.ADDITIONAL_TYPE_RESTRICTION.value = "http://"+str;
		//setTimeout('document.getElementById("invalidURI").innerHTML = ""', 4000);
		return true; 
	}
}

function initIndepClassSel( select ) {
    while (select.options.length > 1)
        select.options[1] = null;

    childrenAsOptions(select, cTop.children, "");

//  history.go(0);
} // initIndepClassSel


function classSelUpdate( select, propName ) {

    while (select.options.length > 0)
        select.options[0] = null;

        if (propName == "")
                return;

    property = eval("p" + propName);
    if (property != null) {
        childrenAsOptions(select, property.range, "");
    }

//  history.go(0);
} // classSelUpdate

function childrenAsOptions(sel, children, offset) {

  for (var i=0; i < children.length; i++) {
    var child = children[i];
    var newLabel = offset + child.label;
    newOpt = new Option(newLabel, child.name, false, false);
    var isAvailable = false;
    for(var j=0; j<sel.options.length; j++){
      if(sel.options[j].value == child.name){
        if(sel.options[j].text.length < newLabel.length){
          sel.options[j] = null;
    sel.options[sel.options.length] = newOpt;


        }
        isAvailable = true;
      }
    } // for
    if(!isAvailable){
        sel.options[sel.options.length] = newOpt;

        if (child.children.length > 0) {
            childrenAsOptions(sel, child.children, offset + "--")
        }
    }
  } // for
} // childrenAsOptions

function classSelOnChange(field) {
	var dep = field.dependent;
	if(dep == null) return;
    for (var i=0; i < dep.length; i++) {
        var propSel = eval( "document.f1." + field.dependent[i]);
        var theProp = trimNS(field.value);
        propSelUpdate(propSel, theProp);
        propSelOnChange(propSel);
		
		
    } // for
} // classSelOnChange
//-----------------------------
// property Select/combobox

function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId, document);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
} 


function propertySel( fieldName, dependentClassVar ) {

    document.write("<select style=\"width:180px\" class=\"select\" name=\"" + fieldName +
                    "\" onChange=\"{propSelOnChange(" + fieldName + "); checkClasses();attrFocus();propcheck();}\">");
    document.write("<option value=\"\"></option>");
    document.write("</select>");

    theSel = document.f1.elements[fieldName];
    theSel.dependent = dependentClassVar;
} // propertySel

function propcheck() {
	if (document.f1.prop1.selectedIndex	!= 0) {
		document.getElementById("ydiv").style.visibility = "visible";
		document.getElementById("ydiv").style.height = "60px";
	} else {
		//alert("document.f1.prop1.selectedIndex = 0");
		document.getElementById("ydiv").style.visibility = "hidden";
		document.getElementById("zdiv").style.visibility = "hidden";
		document.getElementById("ydiv").style.height = "1px";
		document.getElementById("zdiv").style.height = "1px";
		document.f1.nameY.selectedIndex = 0;
		document.f1.nameZ.selectedIndex = 0;
		document.f1.nameYText.value = "";
		document.f1.nameZText.value = "";
		document.getElementById("ytext").style.visibility = "hidden";
		document.getElementById("ytext").style.height = "1px";
	}
	if (document.f1.prop2.selectedIndex	!= 0) {
		document.getElementById("zdiv").style.visibility = "visible";
		document.getElementById("zdiv").style.height = "40px";
	} else {
		//alert("document.f1.prop2.selectedIndex = 0");
		document.getElementById("zdiv").style.visibility = "hidden";
		document.getElementById("zdiv").style.height = "1px";
		//document.f1.nameY.selectedIndex = 0;
		document.f1.nameZ.selectedIndex = 0;
		//document.f1.nameYText.value = "";
		document.f1.nameZText.value = "";
		document.getElementById("ztext").style.visibility = "hidden";
		document.getElementById("ztext").style.height = "1px";
	}

	if (document.f1.attr1.length > 1) {
		document.getElementById("attributeExpr1").style.visibility = "visible";
		document.getElementById("attributeExpr1").style.height = "30px";
		document.getElementById("noAttr").innerHTML = "";
	} else {
		document.getElementById("attributeExpr1").style.visibility = "hidden";
		document.getElementById("attributeExpr1").style.height = "1px";
		document.getElementById("attrEx1").style.visibility = "hidden";
		document.getElementById("attrEx1").style.height = "1px";
		document.f1.attrExpr1.selectedIndex = 0;
	}
	if (document.f1.attr2.length > 1) {
		document.getElementById("attributeExpr2").style.visibility = "visible";
		document.getElementById("attributeExpr2").style.height = "30px";
		document.getElementById("noAttr").innerHTML = "";
	} else {
		document.getElementById("attributeExpr2").style.visibility = "hidden";
		document.getElementById("attributeExpr2").style.height = "1px";
		document.getElementById("attrEx2").style.visibility = "hidden";
		document.getElementById("attrEx2").style.height = "1px";
		document.f1.attrExpr2.selectedIndex = 0;
	}
	if (document.f1.attr3.length > 1) {
		document.getElementById("attributeExpr3").style.visibility = "visible";
		document.getElementById("attributeExpr3").style.height = "30px";
		document.getElementById("noAttr").innerHTML = "";
	} else {
		document.getElementById("attributeExpr3").style.visibility = "hidden";
		document.getElementById("attributeExpr3").style.height = "1px";
		document.getElementById("attrEx3").style.visibility = "hidden";
		document.getElementById("attrEx3").style.height = "1px";
		document.f1.attrExpr3.selectedIndex = 0;
	}
	if (document.f1.attr1.length <= 1 && document.f1.attr2.length <= 1 && document.f1.attr3.length <= 1) {
		document.getElementById("noAttr").innerHTML = "No attributes available.";	
	}
}

function propSelOnChange(field) {
    var theClassSel = eval( "document.f1." + field.dependent);
    if (theClassSel == null)
                return;

    var theClass = trimNS(field.value);
    classSelUpdate(theClassSel, theClass);
    classSelOnChange(theClassSel);
} // propSelOnChange


function propSelUpdate( select, className ) {
    while (select.options.length > 0)
        select.options[0] = null;
    select.options[0] = new Option("---", "", false, false);
    if (className == "")
                return;
    theClass = eval("c" + className);
    if (theClass != null) {
                if (select.name.charAt(0) == 'p') {
				
                        childrenAsOptions(select, theClass.props, "");
				} else {
                        childrenAsOptions(select, theClass.attribs, "");
				}
	}
	

//  history.go(0);
} // propSelUpdate

//-----------------------------
// variable Select/combobox

function varSel(varSelName, vars, dependent) {
    document.write("<select class=\"edit1\" name=\"" + varSelName +
                    "\" onfocus=\"{varSelOnChange(" + varSelName + ");}\">");
//document.write("<option value='a'>---</option>");
    for (var i=0; i<vars.length; i++) {
        document.write("<option value=\"" + vars[i] + "\">" + vars[i] + "</option>");
    }
    document.write("</select>");
//alert(document.f1.varSel5.value);
    theSel = eval("document.f1." + varSelName);
    theSel.dependent = dependent;
    theSel.prevVal = theSel.value;

    newClassSel = eval("document.f1.class" + theSel.value);
    push(newClassSel.dependent,theSel.dependent);
	//alert(dependent);
	//alert(document.f1.classX.value+"\n"+document.f1.classY.value+"\n"+document.f1.classZ.value+"\n");
} // varSel

function varSelOnChange(aVarSel) {
	
    prevClassSel = eval("document.f1.class" + aVarSel.prevVal);
	//alert(aVarSel.prevVal);
    for (var i=0; i < prevClassSel.dependent.length; i++) {
        if (prevClassSel.dependent[i] == aVarSel.dependent) {
            prevClassSel.dependent = splice(prevClassSel.dependent, i, 1);
//            prevClassSel.dependent.splice(i,1);
            break;
        }
    } // for

    newClassSel = eval("document.f1.class" + aVarSel.value);
    push(newClassSel.dependent, aVarSel.dependent);

    var theClass = trimNS(newClassSel.value);
    propSelUpdate(eval( "document.f1." + aVarSel.dependent), theClass);

    aVarSel.preVal = aVarSel.value;	

//attrRestrX();
//attrRestrY();
//attrRestrZ();
	//alert("aVarSel=" + aVarSel.name + "\naVarSel.prevVal=" + aVarSel.prevVal + "\naVarSel.dependent=" + aVarSel.dependent + "\nprevClassSel=" + prevClassSel.name + "\nnewClassSel=" + newClassSel.name + "\nprevClassSel.dependent=" + prevClassSel.dependent + "\nnewClassSel.dependent=" + newClassSel.dependent + "\ntheClass=" + theClass + "\nprevClassSel.dependent[0]=" + prevClassSel.dependent[0]);
} // varSelOnChange

function attrRestrX() {
    newClassSel = eval("document.f1.classX");
    var theClass = trimNS(newClassSel.value);
    propSelUpdate(eval("document.f1.attr1"), theClass);
}
function attrRestrY() {
    newClassSel = eval("document.f1.classY");
    var theClass = trimNS(newClassSel.value);
    propSelUpdate(eval("document.f1.attr2"), theClass);
}
function attrRestrZ() {
    newClassSel = eval("document.f1.classZ");
    var theClass = trimNS(newClassSel.value);
    propSelUpdate(eval("document.f1.attr3"), theClass);
}

// attribute Select/combobox

function attributeSel( fieldName ) {

    document.write("<select style=\"width:180px\" class=\"select\" name=\"" + fieldName + "\">");
    document.write("<option value=\"\"></option>");
    document.write("</select>");

} // attributeSel


//--------------------------------------------
// UI styles and behaviour

// function for edit boxes
function txtNormal(obj) {
        obj.className="edit2";
}
function txtFocus(obj) {
  obj.className="edit2";
  obj.select();
}

// functions for buttons
function btnNormal(obj) {
  obj.className="button1";
}
function btnOnFocus(obj) {
  obj.className="button2";
}

//--------------------------------------------
// select an item in a combobox
function selComboItem(comboControl, matchValue){
	if(comboControl != null){
		for(var i=0; i<comboControl.options.length; i++){
			if(comboControl.options[i].value == matchValue){
				comboControl.selectedIndex = i;
				return;
			}
		}
	}
}

//--------------------------------------------
// trims the NS
function trimNS(value){
	 //alert("Deprecated function trimNS called with param " + value);
     var retStr = value.toString();
//	 var ix = retStr.lastIndexOf('#');
//	 if (ix < 0)
//		 ix = retStr.lastIndexOf(':');
//     if(ix>-1){
//      retStr = retStr.substring(ix+1,retStr.length);
//    }
//    return retStr;

	
	retStr = retStr.replace(new RegExp("[^0-9a-zA-Z_]", "g"), "_");
	return retStr;
}


/* coreScript.jsp */

var restrictions=new Array();var timeoutCount=0;function trim(s){if(s==null)return"";while(s.substring(0,1)==' '){s=s.substring(1,s.length);}
while(s.substring(s.length-1,s.length)==' '){s=s.substring(0,s.length-1);}
return s;}
function checkFilter(s,lim){var retStr=s;for(ix=s.length-1;ix>0;ix--){if(s.substring(ix-1,ix)==' '){if(s.length-ix<lim){retStr=s.substring(0,ix-1);}
break;}}
return trim(retStr);}
function getElement(formID){var i;for(i=0;i<document.f1.elements.length;i++){var element=document.f1.elements[i];if((element.name!=null)&&(element.name==formID)){return element;}}}
function getIFrame(frameID){return window.frames[frameID];}
function checkRelatedConcepts(){var i;for(i=0;i<window.frames.length;i++){if(window.frames[i].name=="RelatedConcepts")return true;}
return false;}
function scheduleEvent(formID,baseUrl,baseUrlRC,timeout,keyCode){setTimeout("checkAndReload('"+formID+"', '"+baseUrl+"', '"+baseUrlRC+"', "+keyCode+")",timeout);timeoutCount++;}
function checkAndReload(formID,baseUrl,baseUrlRC,keyCode){timeoutCount--;if(timeoutCount>0)
return false;var element=getElement(formID);var value=element.value;var filter=trim(value);if((filter.length==1)||((filter.length==2)&&(keyCode!=13)))
return;if(formID=="KeyWords"){var origString=element.value;var inChar="'";var outChar='"';var newString=origString.split(inChar);newString=newString.join(outChar);element.value=newString;location=baseUrl+"&KeyWords="+encode(formID);}else{var frame=getIFrame(formID);frame.location=baseUrl+"&prefix="+encode(formID);if((baseUrlRC.length>0)&&checkRelatedConcepts()){var frameRC=getIFrame("RelatedConcepts");}}
return false;}
function scheduleEvent2(id,formID,baseUrl,baseUrlRC,timeout,keyCode){setTimeout("checkAndReload2('"+id+"', '"+formID+"', '"+baseUrl+"', '"+baseUrlRC+"', "+keyCode+")",timeout);timeoutCount++;}
function checkAndReload2(id,formID,baseUrl,baseUrlRC,keyCode){timeoutCount--;if(timeoutCount>0)
return false;var element=getElement(id);var value=element.value;var filter=trim(value);if((filter.length==1)||((filter.length==2)&&(keyCode!=13)))
return;if(formID=="KeyWords"){var origString=element.value;var inChar="'";var outChar='"';var newString=origString.split(inChar);newString=newString.join(outChar);element.value=newString;location=baseUrl+"&KeyWords="+encode(id);}else{var frame=getIFrame(formID);frame.location=baseUrl+"&prefix="+encode(id);if((baseUrlRC.length>0)&&checkRelatedConcepts()){var frameRC=getIFrame("RelatedConcepts");}}
return false;}
function classCategorySelNoEvent(selectFieldName,width){document.write("<select style=\"width:"+width+"\" class=\"select\" name=\""+selectFieldName+"\">");document.write("</select>");theSel=document.f1.elements[selectFieldName];}
function classCategorySelNoDup(selectFieldName,width){document.write("<select style=\"float: left; width:"+width+"\" class=\"select\" id=\""+selectFieldName+"\" name=\""+selectFieldName+"\"");document.write(" onChange=\"{arrHasDupes('"+selectFieldName+"');}\">");document.write("<option value='-1'>-- Select category --</option>");document.write("</select><div style = \"float: left; cursor: pointer; padding-left: 3px; padding-top: 2px;\" id=\"div"+selectFieldName+"\"></div>");theSel=document.f1.elements[selectFieldName];}
function classCategorySel(selectFieldName,filterFieldName,width){document.write("<select style=\"width:"+width+"\" class=\"select\" name=\""+selectFieldName+"\"");document.write(" onChange=\"{classCategorySelOnChange('"+filterFieldName+"');}\">");document.write("</select>");theSel=document.f1.elements[selectFieldName];}
function classCategorySelOnChange(filterFieldName){var element=getElement(filterFieldName);element.value="";document.f1.submit();}
function categoryFilterChange(formID,baseUrl,selectFieldName,e){var element=getElement(selectFieldName);var value=element.value;scheduleEvent(formID,baseUrl+"category="+escapeVal(value),null,500,e.keyCode);}
function aliasFilterChange(id,formID,baseUrl,baseUrlRC,e){scheduleEvent2(id,formID,baseUrl,baseUrlRC,500,e.keyCode);}
function keywordFilterChange(formID,baseUrl,e){scheduleEvent(formID,baseUrl,null,3000,e.keyCode);}


